package name.sra.png;

import java.awt.Component;
import java.awt.Container;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Image;
import java.awt.Point;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.awt.image.BufferedImage;
import java.io.File;
import java.util.ArrayList;
import java.util.List;

import javax.swing.JApplet;
import javax.swing.JFrame;

public class Printer extends Component {

	private static final int GAP = 10;
	private List<BufferedImage> imgs;
	JFrame frame;
	
	public Printer() {
		frame = new JFrame();
		frame.setMinimumSize(new Dimension(1200, 600));
		frame.setLocation(new Point(30, 60));
		frame.addMouseListener(new MouseListener() {@Override
		public void mouseReleased(MouseEvent e) {
			System.exit(1);
		}

		@Override
		public void mouseClicked(MouseEvent e) { }

		@Override
		public void mouseEntered(MouseEvent e) { }

		@Override
		public void mouseExited(MouseEvent e) { }

		@Override
		public void mousePressed(MouseEvent e) { }});
		imgs = new ArrayList<BufferedImage>();
	}
	
	public void print(List<File> files) {
		for (File file : files) {
			imgs.add(ImageUtils.getImage(file));
		}
		frame.add(this);
		frame.pack();
		frame.setVisible(true);
	}

	@Override
	public void paint(Graphics g) {
		super.paint(g);
		
		for (int i = 0;i < 100;i++) {	
			int rgb = imgs.get(0).getRGB(i, 50);
			String rawRGB = Integer.toHexString(rgb);
			System.out.print(" " + ImageUtils.correctRGB(rawRGB));
			imgs.get(0).setRGB(i, 50, ImageUtils.setLum(rgb, "CC"));
		}
		
		g.drawImage(imgs.get(0), 0, 0, null);
	}
}
